package cn.gok.mapper;

import cn.gok.pojo.Examination;
import cn.gok.pojo.ExcelsPro;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {
    //添加单个题目
    @Insert("insert into practice (question,answer,title,score,serial) values (#{question},#{answer},#{title},#{score},#{serial})")
    public int addExam(ExcelsPro excelsPro);
    //查询试卷名
    @Select("SELECT *  FROM examination WHERE 1=1")
    public List<Examination> selAll();
    //查询所有题目，模糊查询
    @Select("SELECT *  FROM practice WHERE title like '%${title}%'")
    public List<ExcelsPro> selExam(@Param("title") String title);
    //修改数据库
    @Update("update examination SET title=#{title},ip=#{ip},ports=#{ports},`databases`=#{databases},username=#{username},`password`=#{password} WHERE id=#{id}")
    public int update(Examination examination);
    //修改题目
    @Update("UPDATE practice SET question=#{question},answer=#{answer},score=#{score} WHERE id=#{id}")
    public int upexam(ExcelsPro excelsPro);
    //删除题库
    @Delete("DELETE examination,practice FROM examination LEFT JOIN practice ON examination.title=practice.title WHERE examination.id=#{id}")
    public int deldate(int id);
    //删除题目
    @Delete("DELETE FROM practice WHERE id=#{id}")
    public int delexam(int id);
}
